package com.icim.twqc.exporter.job;

import java.io.File;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.icim.core.pojo.FtpConfigure;
import com.icim.core.service.IAlarmSenderService;
import com.icim.core.service.IFtpTwqcService;
import com.icim.twqc.exporter.entity.Prod_process;
import com.icim.dao.HisRetPrdInDao;
import com.icim.dao.HisRetPrdInfoDao;
import com.icim.dao.RetBoxDao;
import com.icim.dao.RetCusPrdIndtDao;
import com.icim.dao.RetCusSoDao;
import com.icim.dao.RetPrdCutDao;
import com.icim.dao.RetPrdInTwqcDao;
import com.icim.dao.RetPrdInfoDao;
import com.icim.dao.RetWoDao;
import com.icim.def.ComDef;
import com.icim.entity.His_ret_prd_in;
import com.icim.entity.His_ret_prd_info;
import com.icim.entity.Ret_prd_cut;
import com.icim.entity.Ret_prd_in_twqc;
import com.icim.entity.Ret_prd_info;
import com.icim.entity.Ret_wo;
import com.icim.util.CsvFileWriterUtil;
import com.icim.util.TimeUtil;
import com.icim.util.ZipCompressUtil;

public class TwqcExportProd_processJob {

    private final static Logger logger = LoggerFactory.getLogger(TwqcExportProd_processJob.class);

    private Timestamp beginTimestamp;
    private Timestamp endTimestamp;
    private String strBeginTime;
    private String strEndTime;
    private FtpConfigure ftpConfigure;
    private int endTimeMak;

    @Resource
    private RetWoDao retWoDao;
    @Resource
    private RetPrdInfoDao retPrdInfoDao;
    @Resource
    private RetCusSoDao retCusSoDao;
    @Resource
    private RetCusPrdIndtDao retCusPrdIndtDao;
    @Resource
    private HisRetPrdInDao hisRetPrdInDao;
    @Resource
    private RetBoxDao retBoxDao;
    @Resource
    private RetPrdCutDao retPrdCutDao;
    @Resource
    private RetPrdInTwqcDao retPrdInTwqcDao;
    @Resource
    private HisRetPrdInfoDao hisRetPrdInfoDao;
    private IFtpTwqcService ftpService;
    @Resource
    private IAlarmSenderService alarmSenderService;

    public void subMainProc() {
        logger.info("export twqc history system running .....");

        /**
         * get time period : begin time & end time
         */
        try {
            getTimePeriod();
			subMainProc2();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			String errorMsg="his数据回传失败，开始时间："+beginTimestamp+"  结束时间："+endTimestamp+"\n"+"失败原因："+e.getMessage();
        	alarmSenderService.sendAlarm1("232",errorMsg);
		}

        logger.info("export twqc history data successfull ......");
    }

    public void subMainProc2() throws Exception {
        /**
         * get all work order by custom id
         */
        List<Ret_wo> woList = findAllWorkerOrder();

        /**
         * query table HIS_RET_PRD_INFO by custom_id & time period
         */
        
        List<His_ret_prd_info> sheetHistories = hisRetPrdInfoDao.findSheets(woList, beginTimestamp, endTimestamp);
        //增加来料记录的回传逻辑
        List<His_ret_prd_in> his_ret_prd_in_List = hisRetPrdInDao.findBox(woList,beginTimestamp, endTimestamp);
        //增加切割站点的信息回传
        List<Ret_prd_info> ret_prd_info_List = retPrdInfoDao.findSheets(woList, beginTimestamp, endTimestamp);
        logger.info("find {} records in his_ret_prd_info....", sheetHistories.size());
        logger.info("find {} records in his_ret_prd_in....", his_ret_prd_in_List.size());
        logger.info("find {} records in ret_prd_info....", ret_prd_info_List.size());
        if (sheetHistories.size() == 0 && his_ret_prd_in_List.size()==0 && ret_prd_info_List.size()==0) {
            return;
        }
    
        /**
         * loop sheets make tFile
         */
        sheetHistories = filterHistory(sheetHistories);
        his_ret_prd_in_List = filterRetPrdIn(his_ret_prd_in_List);
        List<Prod_process> tEntityList = new ArrayList<Prod_process>();
        if(ret_prd_info_List.size() != 0)
        {
        	//info表，大板记录
        	for(Ret_prd_info ret_prd_info : ret_prd_info_List )
        	{
        		Prod_process tEntity0 = new Prod_process();
        		List<Ret_wo> ret_wo_List = retWoDao.getWo(ret_prd_info.getWo_id_fk());
        		tEntity0.setShipping_id(ret_wo_List.get(0).getMtrl_prod_id_fk());
        		tEntity0.setVendor("WGT");
        		String mdl_cate_fk = ret_wo_List.get(0).getMdl_cate_fk();
	            if(mdl_cate_fk.equals("A"))
	            {
	            	//减薄后型号
	            	tEntity0.setReturn_id(ret_wo_List.get(0).getMdl_id_fk());
	            }
	            else if(mdl_cate_fk.equals("AB") || mdl_cate_fk.equals("B"))
	            {
	            	//镀膜后型号
	            	tEntity0.setReturn_id(ret_wo_List.get(0).getFm_mdl_id_fk());
	            }
	            else if(mdl_cate_fk.equals("AC") || mdl_cate_fk.equals("ABC") || mdl_cate_fk.equals("BC") || mdl_cate_fk.equals("C"))
	            {
	            	//切割后型号
	            	tEntity0.setReturn_id(ret_wo_List.get(0).getCut_mdl_id_fk());
	            }
	            String glassId = ret_prd_info.getPrd_seq_id().split("_")[0];
                if(ret_prd_info.getPrd_seq_typ().equals("M") && ret_prd_info.getMdl_id_fk().equals("2422A1013503H")){
                	glassId = glassId.substring(0, glassId.length()-2);
                }
	            tEntity0.setSht_id(glassId);
        		tEntity0.setCut_id(null);
        		tEntity0.setPanel_id(null);
        		tEntity0.setStation(ret_prd_info.getCr_ope_id_fk());
        		tEntity0.setType("move out");
        		String evt_timestamp = ret_prd_info.getEvt_timestamp().toString();
	            String YYYYMMDD = evt_timestamp.substring(0, 10).replace("-", "");
	            String HHMMSS = evt_timestamp.substring(11,19).replace(":", "");
	            tEntity0.setTime(YYYYMMDD+"-"+HHMMSS);
        		
        		tEntityList.add(tEntity0);
	            //获取中板id,回传中板信息
        		String product_id = ret_prd_info.getPrd_seq_id();
        		List<Ret_prd_cut> ret_prd_cut_list = retPrdCutDao.getCutListByPVID(product_id);
        		logger.info("find {} records in ret_prd_cut ....",ret_prd_cut_list.size());
        		for(Ret_prd_cut ret_prd_cut : ret_prd_cut_list)
        		{
        			Prod_process tEntity = new Prod_process();
        			String Cut_id = ret_prd_cut.getPRD_SEQ_ID();
        			List<Ret_wo> ret_wo_List0 = retWoDao.getWo(ret_prd_cut.getWO_ID_FK());
            		tEntity.setShipping_id(ret_wo_List0.get(0).getMtrl_prod_id_fk());
            		tEntity.setVendor("WGT");
            		String mdl_cate_fk0 = ret_wo_List0.get(0).getMdl_cate_fk();
    	            if(mdl_cate_fk0.equals("A"))
    	            {
    	            	tEntity.setReturn_id(ret_wo_List0.get(0).getMdl_id_fk());
    	            }
    	            else if(mdl_cate_fk0.equals("AB") || mdl_cate_fk0.equals("B"))
    	            {
    	            	tEntity.setReturn_id(ret_wo_List0.get(0).getFm_mdl_id_fk());
    	            }
    	            else if(mdl_cate_fk0.equals("AC") || mdl_cate_fk0.equals("ABC") || mdl_cate_fk0.equals("BC") || mdl_cate_fk0.equals("C"))
    	            {
    	            	tEntity.setReturn_id(ret_wo_List0.get(0).getCut_mdl_id_fk());
    	            }
        			tEntity.setSht_id(null);
        			String gID = ret_prd_info.getPrd_seq_id().split("_")[0];
                    if(ret_prd_info.getPrd_seq_typ().equals("M") && ret_prd_info.getMdl_id_fk().equals("2422A1013503H")){
                    	gID = gID.substring(0, gID.length()-2);
                    }
            		tEntity.setCut_id(gID);
            		tEntity.setPanel_id(null);
            		tEntity.setStation(ret_prd_cut.getCR_OPE_ID_FK());
            		tEntity.setType("move out");
            		String evt_timestamp0 = ret_prd_cut.getEVT_TIMESTAMP().toString();
    	            String YYYYMMDD0 = evt_timestamp0.substring(0, 10).replace("-", "");
    	            String HHMMSS0 = evt_timestamp0.substring(11,19).replace(":", "");
    	            tEntity.setTime(YYYYMMDD0+"-"+HHMMSS0);
            		
            		tEntityList.add(tEntity);
        		}
        	}
        }
        
        if(sheetHistories.size() != 0)
        {
	        for (His_ret_prd_info hisRetPrdInfo : sheetHistories) {
	        	List<Ret_wo> ret_wo = retWoDao.getWo(hisRetPrdInfo.getWo_id_fk());
	        	Prod_process tEntity = new Prod_process();
	            tEntity.setVendor("WGT");
	            tEntity.setShipping_id(hisRetPrdInfo.getMtrl_prod_id_fk());
	            //mdl_cate_fk是从his_ret_prd_info表里读取的，不是ret_wo
	            String mdl_cate_fk = hisRetPrdInfo.getMdl_cate_fk();
	            if(mdl_cate_fk.equals("A"))
	            {
	            	//减薄后型号
	            	tEntity.setReturn_id(ret_wo.get(0).getMdl_id_fk());
	            }
	            else if(mdl_cate_fk.equals("AB") || mdl_cate_fk.equals("B"))
	            {
	            	//镀膜后型号
	            	tEntity.setReturn_id(ret_wo.get(0).getFm_mdl_id_fk());
	            }
	            else if(mdl_cate_fk.equals("AC") || mdl_cate_fk.equals("ABC") || mdl_cate_fk.equals("BC") || mdl_cate_fk.equals("C"))
	            {
	            	//切割后型号
	            	tEntity.setReturn_id(ret_wo.get(0).getCut_mdl_id_fk());
	            }
	            String prd_type = hisRetPrdInfo.getPrd_seq_typ();
	            String prd_seq_id = rebuildProId(hisRetPrdInfo.getPrd_seq_id());
                if(hisRetPrdInfo.getPrd_seq_typ().equals("M") && hisRetPrdInfo.getMdl_id_fk().equals("2422A1013503H")){
                	prd_seq_id = prd_seq_id.substring(0, prd_seq_id.length()-2);
                }
	            //解决玻璃id带有下划线的问题
	            if(prd_type.equals("S"))
	            {
	            	tEntity.setSht_id(prd_seq_id);
	                tEntity.setCut_id(null);
	                tEntity.setPanel_id(null);
	            }
	            else if(prd_type.equals("M"))
	            {
	            	tEntity.setSht_id(null);
	                tEntity.setCut_id(prd_seq_id);
	                tEntity.setPanel_id(null);
	            }
	            else if(prd_type.equals("P"))
	            {
	            	tEntity.setSht_id(null);
	                tEntity.setCut_id(null);
	                tEntity.setPanel_id(prd_seq_id);
	            }
	            String type = hisRetPrdInfo.getEvt_cate();
	            if(type.equals("LGON"))
	            {
	            	tEntity.setType("move in");
	            	tEntity.setStation(hisRetPrdInfo.getCr_ope_id_fk());
	            }
	            else if(type.equals("LGOF"))
	            {
	            	tEntity.setType("move out");
	            	tEntity.setStation(hisRetPrdInfo.getCr_ope_id_fk());
	            }
	            else if(type.equals("WHIN"))
	            {
	            	tEntity.setType("move in");
	            	tEntity.setStation("CPCK");
	            }
	            else if(type.equals("WHOT"))
	            {
	            	tEntity.setType("move out");
	            	tEntity.setStation("CPCK");
	            }
	            else if(type.equals("STBI"))
	            {
	            	tEntity.setType("move in");
	            	tEntity.setStation(hisRetPrdInfo.getCr_ope_id_fk());
	            }
	            String evt_timestamp = hisRetPrdInfo.getEvt_timestamp().toString();
	            String YYYYMMDD = evt_timestamp.substring(0, 10).replace("-", "");
	            String HHMMSS = evt_timestamp.substring(11,19).replace(":", "");
	            tEntity.setTime(YYYYMMDD+"-"+HHMMSS);
	            tEntityList.add(tEntity);
	        }
        }
        if(his_ret_prd_in_List.size() != 0)
        {
        	for(His_ret_prd_in hisRetPrdIn : his_ret_prd_in_List)
        	{
        		//判断工单类型，只回传S类型的
        		String wo_id = hisRetPrdIn.getWo_id_fk();
        		String plant_id = retWoDao.getWo(wo_id).get(0).getPlantID();
        		if(!"S".equals(plant_id)){
        			continue;
        		}
        		String boxId = hisRetPrdIn.getMtrl_box_id();
        		String realId = retBoxDao.getBoxListByBoxId(boxId).get(0).getBoxrealid();
	        	List<Ret_prd_in_twqc> ret_prd_in_List = retPrdInTwqcDao.getRetPrdInListByBox(realId);
	        	if(ret_prd_in_List.size()==0)
	        	{
	        		logger.info("在来料表中未找到箱号为"+realId+"的记录!!!");
	        		continue;
	        	}
	        	//取到最新一笔数据的时间
	        	String CurTime = ret_prd_in_List.get(0).getEVT_TIMESTAMP();
	        	List<Ret_prd_in_twqc> ret_prd_in_List0 = retPrdInTwqcDao.getRetPrdInListByBoxAndTime(realId, CurTime);
	        	for(Ret_prd_in_twqc retPrdIn : ret_prd_in_List0){
	        		//为回传的来料数据赋值
	        		Prod_process tEntity = new Prod_process();
	        		tEntity.setVendor("WGT");
	        		tEntity.setStation("RMCK");
	        		//读取的是his_ret_prd_in的evt_timestamp
	        		String evt_timestamp = hisRetPrdIn.getEvt_timestamp().toString();
		            String YYYYMMDD = evt_timestamp.substring(0, 10).replace("-", "");
		            String HHMMSS = evt_timestamp.substring(11,19).replace(":", "");
		            tEntity.setTime(YYYYMMDD+"-"+HHMMSS);
		            List<Ret_wo> ret_wo_List = retWoDao.getWo(hisRetPrdIn.getWo_id_fk());
		            String mdl_cate_fk = ret_wo_List.get(0).getMdl_cate_fk();
		            //加工前料号
	        		tEntity.setShipping_id(ret_wo_List.get(0).getMtrl_prod_id_fk());
		            if(mdl_cate_fk.equals("A"))
		            {
		            	//减薄后型号
		            	tEntity.setReturn_id(ret_wo_List.get(0).getMdl_id_fk());
		            }
		            else if(mdl_cate_fk.equals("AB") || mdl_cate_fk.equals("B"))
		            {
		            	//镀膜后型号
		            	tEntity.setReturn_id(ret_wo_List.get(0).getFm_mdl_id_fk());
		            }
		            else if(mdl_cate_fk.equals("AC") || mdl_cate_fk.equals("ABC") || mdl_cate_fk.equals("BC") || mdl_cate_fk.equals("C"))
		            {
		            	//切割后型号
		            	tEntity.setReturn_id(ret_wo_List.get(0).getCut_mdl_id_fk());
		            }
		        	tEntity.setSht_id(retPrdIn.getGLASSID());
	        		String type = hisRetPrdIn.getEvt_cate();
	        		if(type.equals("MTIN"))
	        		{
	        			tEntity.setType("move in");
	        		}
	        		else if(type.equals("MTRP"))
	        		{
	        			tEntity.setType("move out");
	        		}
		            tEntityList.add(tEntity);
	        	}
        	}
        }
        if (tEntityList.isEmpty()) {
			return;
		}
        List<String[]> bodyList = new ArrayList<String[]>();
        for (Prod_process entity : tEntityList) {
            String[] body = new String[] { entity.getVendor(),entity.getShipping_id(),entity.getReturn_id(),entity.getSht_id(),
            		entity.getCut_id(),entity.getPanel_id(),entity.getStation(),entity.getType(),entity.getTime()
            };
            logger.info(entity.toString());
            bodyList.add(body);
        }
        
        String fileName = getFtpConfigure().getLocalProd_processGzPath().trim()+"/PROD_Process_" + getCurrentTimeStr() + ".csv";
        try {
        	String[] headers = { "VENDOR", "SHIPPING_ID", "RETURN_ID", "SHT_ID", "CUT_ID", "PANEL_ID",
                    "STATION", "TYPE", "TIME" };
            
            logger.info("building csv file process [" + fileName + "]");
            CsvFileWriterUtil.writeCVS("SLIM_EDC_DATA_BEGIN", headers, bodyList, "SLIM_EDC_DATA_END", fileName);
            logger.info("compress csv file process ....");
            
            ZipCompressUtil.compress(new File(fileName));
            String gzFileName = fileName + ".zip";
            File gzFile = new File(gzFileName);

            // send to FTP Service
            ftpService.connect();
            ftpService.uploadFile(gzFile, getFtpConfigure().getFtpProd_processExportPath());
            ftpService.disconnectFtp();
            logger.info("=============================================================================");
        } catch (Exception e) {
        	e.printStackTrace();
            logger.error(e.toString());
            throw e;
        }
    }
    
    private String rebuildProId(String id)
    {
    	String newid = "";
    	if(id.contains("_"))
    	{
    		int index = id.indexOf("_");
    		newid = id.substring(0,index);
    		return newid;
    	}
    	else
    	{
    		return id;
    	}
    }
    
    private List<His_ret_prd_info> filterHistory(List<His_ret_prd_info> sheetHistories) {
    	List<His_ret_prd_info> fiterHistoryList = new ArrayList<His_ret_prd_info>();
    	
    	
    	Map<String ,His_ret_prd_info> stbiHistoryMap =new HashMap<String,His_ret_prd_info>();
    	//Map<String ,His_ret_prd_info> lgonHistoryMap =new HashMap<String,His_ret_prd_info>();
    	
    	for (His_ret_prd_info hisRetPrdInfo : sheetHistories) {
    		
    		String prdSeqId = hisRetPrdInfo.getPrd_seq_id();
    		//filter the newest STBI history to HashMap
    		if("STBI".equals(hisRetPrdInfo.getEvt_cate())){
    			His_ret_prd_info stbiHisRetPrdInfo = stbiHistoryMap.get(prdSeqId);
    			if(stbiHisRetPrdInfo ==null){
    				stbiHistoryMap.put(prdSeqId,hisRetPrdInfo);
    			}else{
    				if(hisRetPrdInfo.getEvt_timestamp().after(stbiHisRetPrdInfo.getEvt_timestamp())){
    					stbiHistoryMap.put(prdSeqId,hisRetPrdInfo);
    				}
    			}
    		}
    		else{
    			fiterHistoryList.add(hisRetPrdInfo);
    		}
		}
    	
    	//add the newest STBI history
    	Set<Entry<String, His_ret_prd_info>> stbiHistoryEntrySet = stbiHistoryMap.entrySet();
    	for (Entry<String, His_ret_prd_info> stbiHistoryEntry : stbiHistoryEntrySet) {
    		fiterHistoryList.add(stbiHistoryEntry.getValue());
		}
    	
    	return fiterHistoryList;
	}
    
    private List<His_ret_prd_in> filterRetPrdIn(List<His_ret_prd_in> hisRetPrdInList){
    	//取第一次的数据，需要把其他的过滤掉
    	//存放最终的过滤好的数据
    	List<His_ret_prd_in> finalHisPrdInList = new ArrayList<His_ret_prd_in>();
    	//中间过渡容器
    	List<His_ret_prd_in> tempHisPrdInList = new ArrayList<His_ret_prd_in>();
    	
    	try{
    		for(His_ret_prd_in hisRetPrdInTemp : hisRetPrdInList){
        		
        		if(finalHisPrdInList.size()==0){
        			finalHisPrdInList.add(hisRetPrdInTemp);
        		}else{
        			//每次遍历都要和前面的做比较
        			int i = 0;
        			for(His_ret_prd_in finalListTemp : finalHisPrdInList){
        				i++;
        				if(hisRetPrdInTemp.getMtrl_box_id().equals(finalListTemp.getMtrl_box_id()) && hisRetPrdInTemp.getEvt_cate().equals(finalListTemp.getEvt_cate())){
        					//同一箱子，同一个事件,不用判断时间了，因为查出来的就是按照时间升序排列的，所以后面查到的字段一定是舍弃的
        					break;
        				}else{
        					//不相等的话需要遍历完毕，一直到最后一个都没有一样的话再加进来
        					if(i==finalHisPrdInList.size()){
        						tempHisPrdInList.add(hisRetPrdInTemp);
        					}
        					continue;
        				}
        			}
        			//把过渡容器中的元素全部添加到最终集合中
        			for(His_ret_prd_in temp : tempHisPrdInList){
        				finalHisPrdInList.add(temp);
        			}
        			tempHisPrdInList.clear();
        		}
        	}
    	}catch(Exception e){
    		logger.info(e.toString());
    	}
    	
    	logger.info("fiterHisPrdInList.size===="+finalHisPrdInList.size());
    	/*for(His_ret_prd_in s : finalHisPrdInList){
    		logger.info(s.getMtrl_box_id()+"==="+s.getEvt_cate()+"==="+s.getEvt_timestamp());
    	}*/
    	return finalHisPrdInList;
    }
    /**
     * 
     */
    private void getTimePeriod() {
        DateTime dt = new DateTime();

        DateTime endDt = dt.plusMinutes(endTimeMak);
        endTimestamp = new Timestamp(endDt.getMillis());

        DateTime beginDt = endDt.plusHours(-2);
        beginTimestamp = new Timestamp(beginDt.getMillis());

        
        strEndTime = getTimeFromDateTime(endDt);
        strBeginTime = getTimeFromDateTime(beginDt);
        beginTimestamp.setNanos(0);
        endTimestamp.setNanos(0);

        logger.info("begin time:" + beginTimestamp);
        logger.info("end time :" + endTimestamp);
    }
    
    private String getTimeFromDateTime(DateTime dt) {
               return comInt2String(dt.getYear(), 4) + comInt2String(dt.getMonthOfYear(), 2)
                        + comInt2String(dt.getDayOfMonth(), 2) + comInt2String(dt.getHourOfDay(), 2)
                        + comInt2String(dt.getMinuteOfHour(), 2) + comInt2String(dt.getSecondOfMinute(),2);
    }

    private List<Ret_wo> findAllWorkerOrder() {
        return retWoDao.findWoListByCusId(ComDef.TWQC_CUS_ID);
    }

    public static void main(String[] args) {
        new TwqcExportProd_processJob().getTimePeriod();
    }

    public Timestamp getBeginTimestamp() {
        return beginTimestamp;
    }

    public void setBeginTimestamp(Timestamp beginTimestamp) {
        this.beginTimestamp = beginTimestamp;
    }

    public Timestamp getEndTimestamp() {
        return endTimestamp;
    }

    public void setEndTimestamp(Timestamp endTimestamp) {
        this.endTimestamp = endTimestamp;
    }

    public String getStrBeginTime() {
        return strBeginTime;
    }

    public void setStrBeginTime(String strBeginTime) {
        this.strBeginTime = strBeginTime;
    }

    public String getStrEndTime() {
        return strEndTime;
    }

    public void setStrEndTime(String strEndTime) {
        this.strEndTime = strEndTime;
    }

    public FtpConfigure getFtpConfigure() {
        return ftpConfigure;
    }

    public void setFtpConfigure(FtpConfigure ftpConfigure) {
        this.ftpConfigure = ftpConfigure;
    }

    public String comInt2String(int value, int length) {
        String s = String.valueOf(value);
        if (s.length() > length) {
            throw new RuntimeException("length is too short.");
        } else if (s.length() == length) {
            return s;
        } else {
            char[] cc = new char[length];
            int i = 0;
            for (; i < length - s.length(); i++) {
                cc[i] = '0';
            }
            for (int j = 0; j < s.length(); i++, j++) {
                // System.out.println(i);
                cc[i] = s.charAt(j);
            }
            return new String(cc);
        }
    }
    
    public String getCurrentTimeStr()
	{
		Timestamp currentTime = TimeUtil.getCurrentTimestamp();
		String timeStr = currentTime.toString();
		String YYYYMMDD = timeStr.substring(0, 10).replace("-", "");
        String HHMMSS = timeStr.substring(11,19).replace(":", "");
        return YYYYMMDD+HHMMSS;
	}

	public IFtpTwqcService getFtpService() {
		return ftpService;
	}

	public void setFtpService(IFtpTwqcService ftpService) {
		this.ftpService = ftpService;
	}

	public int getEndTimeMak() {
		return endTimeMak;
	}

	public void setEndTimeMak(int endTimeMak) {
		this.endTimeMak = endTimeMak;
	}

}
